package com.achartengine.test.activity;

import android.graphics.Color;
import android.os.Bundle;

import com.achartengine.test.GraphUtils;
import com.achartengine.test.Test;

import org.achartengine.GraphicalView;

/**
 * Author: dengdayi
 * Date:2016/1/11 16:04
 * Description:曲线图
 */
public class CurveActivity extends BaseActivity {

    private GraphicalView mGraphicalView;

    @Override
    public void onCreateBase(Bundle savedInstanceState) {
        mTvTitle.setText("曲线图");

        graphicalView();

        if (mFrameLayout.getChildCount() > 0) {
            mFrameLayout.removeAllViews();
        }

        if (mGraphicalView != null) {
            mFrameLayout.addView(mGraphicalView);
        }
    }

    /**
     * 初始化数据
     */
    private void graphicalView() {
        String[] sub = new String[]{"GRADE"};
        Integer[] color = new Integer[]{Color.BLUE, Color.GREEN,
                Color.MAGENTA, Color.RED};
        mGraphicalView = (GraphicalView) GraphUtils.getLineChartViewOfNum(this, Test.getStudentGradeLists(),
                sub, color);

    }
}
